package com.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Controller
public class UserController {
    //使用RESTful风格完成user数据的crud
    //相同的url设置不同的请求方式 实现不同的处理结果
    @RequestMapping(value = "/user/{id}",method = RequestMethod.GET)
    @ResponseBody
    public void select(@PathVariable int id){
        System.out.println("查询id为"+id+"的user数据");
    }
    @RequestMapping(value = "/user",method = RequestMethod.POST)
    @ResponseBody
    public void insert(@RequestBody User user){
        System.out.println("添加数据"+user);
    }
    @RequestMapping(value = "/user",method = RequestMethod.PUT)
    @ResponseBody
    public void update(@RequestBody User user){
        System.out.println("修改数据"+user);
    }
    @RequestMapping(value = "/user/{id}",method = RequestMethod.DELETE)
    @ResponseBody
    public void delete(@PathVariable int id){
        System.out.println("删除id为"+id+"的user数据");
    }
}
